import _ from 'lodash'

/**
 * env工具
 * @author ellwood
 * @date 2024-10-28
 * @version 1.0.0
 */
const env: any = _.cloneDeep(import.meta.env)

Object.entries(import.meta.env as Record<string, any>).forEach(
  ([key, value]) => {
    if (value === 'true' || value === 'false')
      env[key] = value === 'true'
    else if (/^\d+$/.test(value))
      env[key] = Number(value)
    else if (value === 'null')
      env[key] = null
    else if (value === 'undefined')
      env[key] = undefined
  },
)

export default env as ImportMetaEnv
